﻿<%@ Page Title="Phường/Xã" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Wards.aspx.cs" Inherits="CompanyManagement.management.Wards" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <script type="text/javascript">
        function onRequestStart(sender, args) {
            if (args.get_eventTarget().indexOf("ExportToExcelButton") >= 0) {
                args.set_enableAjax(false);
            }
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="SiteMapContent" runat="server">
    <div id="breadcrumbs">
        <ul class="breadcrumb">
            <li>
                <i class="icon-home"></i>
                <a href="#">Trang chủ</a>

                <span class="divider">
                    <i class="icon-angle-right"></i>
                </span>
            </li>
            <li class="active">Quản lý Phường/Xã</li>
        </ul>
        <!--.breadcrumb-->

        <div id="nav-search">
        </div>
        <!--#nav-search-->
    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    <h3 class="lighter">
        <i class="icon-rss orange"></i>
        Quản lý Phường/Xã
    </h3>
    <telerik:RadCodeBlock ID="DoubleClick" runat="server">
        <script type="text/javascript">
            function RowDblClick(sender, eventArgs) {
                sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
            }
        </script>
    </telerik:RadCodeBlock>
    <telerik:RadSkinManager ID="QsfSkinManager" runat="server" ShowChooser="false" Skin="WebBlue" />
    <telerik:RadFormDecorator ID="QsfFromDecorator" runat="server" DecoratedControls="All"
        EnableRoundedCorners="false" />
    <telerik:RadAjaxManager ID="RadAjaxManager1" EnableAJAX="true" runat="server">
        <ClientEvents OnRequestStart="onRequestStart"></ClientEvents>
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1"></telerik:AjaxUpdatedControl>
                    <telerik:AjaxUpdatedControl ControlID="success"></telerik:AjaxUpdatedControl>
                    <telerik:AjaxUpdatedControl ControlID="error"></telerik:AjaxUpdatedControl>
                    <telerik:AjaxUpdatedControl ControlID="RadWindowManager1"></telerik:AjaxUpdatedControl>
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
    </telerik:RadAjaxLoadingPanel>
    <div class="alert alert-block alert-success" id="success" runat="server" visible="false">
        <asp:Literal ID="ltrSuccess" runat="server"></asp:Literal>
    </div>
    <div class="alert alert-block alert-error" id="error" runat="server" visible="false">
        <asp:Literal ID="ltrError" runat="server"></asp:Literal>
    </div>
    <telerik:RadGrid ID="RadGrid1" runat="server" AllowAutomaticDeletes="false" AllowAutomaticInserts="false" PageSize="10"
        AllowAutomaticUpdates="false" AllowPaging="True" AllowSorting="True" CellSpacing="0"
        AllowFilteringByColumn="True" FilterMenu-EnableTextHTMLEncoding="True" FilterMenu-AppendDataBoundItems="True"
        GridLines="None" OnNeedDataSource="RadGrid1_NeedDataSource" OnItemCommand="RadGrid1_ItemCommand" OnItemDataBound="RadGrid1_ItemDataBound" 
        OnItemCreated="RadGrid1_ItemCreated" OnInsertCommand="RadGrid1_InsertCommand" OnDeleteCommand="RadGrid1_DeleteCommand" 
        OnUpdateCommand="RadGrid1_UpdateCommand">
        <ExportSettings ExportOnlyData="True" IgnorePaging="True">
            <Excel Format="Biff" />
        </ExportSettings>
        <ClientSettings>
            <Selecting AllowRowSelect="true"></Selecting>
            <Scrolling AllowScroll="True" ScrollHeight="" FrozenColumnsCount="2"></Scrolling>
            <ClientEvents OnRowDblClick="RowDblClick"></ClientEvents>
        </ClientSettings>
        <MasterTableView AutoGenerateColumns="False" CommandItemDisplay="Top" DataKeyNames="ID"
            InsertItemPageIndexAction="ShowItemOnFirstPage">
            <CommandItemSettings ExportToPdfText="Export to PDF" AddNewRecordText="Thêm mới"
                ExportToExcelText="Xuất Excel" RefreshText="Làm mới" ShowExportToExcelButton="True"
                ShowAddNewRecordButton="True"></CommandItemSettings>
            <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
                <HeaderStyle Width="20px"></HeaderStyle>
            </RowIndicatorColumn>
            <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
                <HeaderStyle Width="20px"></HeaderStyle>
            </ExpandCollapseColumn>
            <Columns>
                <telerik:GridBoundColumn DataField="ID" DataType="System.Int32" AllowFiltering="false"
                    HeaderText="ID" Visible="false" SortExpression="ID" UniqueName="ID">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Code"
                    HeaderText="Mã Phường/Xã" SortExpression="Code" UniqueName="Code" Visible="True">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Name"
                    HeaderText="Tên Phường/Xã" SortExpression="Name" UniqueName="Name">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="NameFilter"
                    SortExpression="NameFilter" UniqueName="NameFilter" Visible="false">
                </telerik:GridBoundColumn>
                <%--<telerik:GridBoundColumn DataField="District.Name"
                    HeaderText="Thuộc Quận/Huyện" SortExpression="District.Name" UniqueName="District.Name">
                </telerik:GridBoundColumn>--%>
                <telerik:GridDropDownColumn DataField="DistrictID" SortExpression="DistrictID" UniqueName="DistrictID" DataSourceID="EntityDataSource1"
                    ListTextField="Name" ListValueField="ID" HeaderText="Thuộc Quận/Huyện"  ColumnEditorID="GridDropDownColumnEditor1">
                    <FilterTemplate>
                        <telerik:RadComboBox ID="RadComboBoxDistrict" DataSourceID="EntityDataSource1" DataTextField="Name"
                            DataValueField="ID" Height="150px" AppendDataBoundItems="true" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("DistrictID").CurrentFilterValue %>'
                            runat="server" OnClientSelectedIndexChanged="DistrictIndexChanged">
                            <Items>
                                <telerik:RadComboBoxItem Text="All" />
                            </Items>
                        </telerik:RadComboBox>
                        <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
                            <script type="text/javascript">
                                function DistrictIndexChanged(sender, args) {
                                    var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                    tableView.filter("DistrictID", args.get_item().get_value(), "EqualTo");
                                }
                            </script>
                        </telerik:RadScriptBlock>
                    </FilterTemplate>
                </telerik:GridDropDownColumn>
                <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" EditText="Sửa" CancelText="Hủy" UpdateText="Lưu thay đổi" InsertText="Lưu">
                </telerik:GridEditCommandColumn>
                <telerik:GridButtonColumn UniqueName="DeleteColumn" Text="Xóa" ConfirmTitle="Xác nhận" ConfirmDialogType="RadWindow" ConfirmTextFormatString="Bạn có muốn xóa phường/xã:'{0}' không?"
                    ConfirmTextFields="Name" CommandName="Delete" ConfirmDialogWidth="350px" ConfirmDialogHeight="150px">
                </telerik:GridButtonColumn>
            </Columns>
            <EditFormSettings UserControlName="/usercontrol/UcEditWard.ascx" EditFormType="WebUserControl" InsertCaption="Thêm mới phường/xã" CaptionFormatString="Sửa thông tin Phường/xã: {0}" CaptionDataField="ID">
            </EditFormSettings>
        </MasterTableView>
        <ValidationSettings CommandsToValidate="PerformInsert,Update" />
        <FilterMenu EnableImageSprites="False">
        </FilterMenu>
    </telerik:RadGrid>
    <asp:EntityDataSource ID="EntityDataSource1" runat="server" ConnectionString="name=CompanyEntities" DefaultContainerName="CompanyEntities" EnableFlattening="False" EntitySetName="Districts"
        Where="it.[IsActive] = True"></asp:EntityDataSource>
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
    </telerik:RadWindowManager>
</asp:Content>
